package com.easyUtils.utils.resultUtil;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一返回类
 * @param <T>
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    private String code;
    private String msg;
    private T data;

    public static <T> Result<T> success(T data) {
        return new Result<T>("200", "操作成功", data);
    }

    public static <T> Result<T> error(String code, String msg) {
        return new Result<T>(code, msg, null);
    }

    public static <T> Result<T> error(String msg) {
        return new Result<T>("500", msg, null);
    }

    public static <T> Result<T> error() {
        return new Result<T>("500", "操作失败", null);
    }

    public static <T> Result<T> error(T data) {
        return new Result<T>("500", "操作失败", data);
    }
    public static <T> Result<T> error(String code, String msg, T data) {
        return new Result<T>(code, msg, data);
    }
    public static <T> Result<T> error(String msg, T data) {
        return new Result<T>("500", msg, data);
    }

}
